package QualificationRound.T9Spelling;

import java.util.Scanner;

public class Main {

    private static int casos;
    private static Scanner consola = new Scanner(System.in);
    private static char sms[];
    private static StringBuilder salida = new StringBuilder();

    public static void main(String[] args) {

        //Cantidad de casos
        casos = consola.nextInt();
        consola.nextLine();
        //para los distintos casos
        for (int j = 0; j < casos; j++) {
            sms = consola.nextLine().toCharArray();
            salida.append("Case #").append(j + 1).append(": ");
            for (int i = 0; i < sms.length; i++) {
                char letra = sms[i];
                String teclado = getNumber(letra);
                if (salida.charAt(salida.length()-1)==teclado.charAt(0)){
                    salida.append(" ");
                }
                salida.append(teclado);
            }
            salida.append("\n");
        }
        System.out.print(salida);
    }

    public static String getNumber(char c) {

        switch (c) {

            case 'a':
                return "2";
            case 'b':
                return "22";
            case 'c':
                return "222";
            case 'd':
                return "3";
            case 'e':
                return "33";
            case 'f':
                return "333";
            case 'g':
                return "4";
            case 'h':
                return "44";
            case 'i':
                return "444";
            case 'j':
                return "5";
            case 'k':
                return "55";
            case 'l':
                return "555";
            case 'm':
                return "6";
            case 'n':
                return "66";
            case 'o':
                return "666";
            case 'p':
                return "7";
            case 'q':
                return "77";
            case 'r':
                return "777";
            case 's':
                return "7777";
            case 't':
                return "8";
            case 'u':
                return "88";
            case 'v':
                return "888";
            case 'w':
                return "9";
            case 'x':
                return "99";
            case 'y':
                return "999";
            case 'z':
                return "9999";
            case ' ':
                return "0";
        }
        return "error";
    }
}
